﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace elfam.web.Utils
{
    public class MailUtils
    {
        public static string RenderViewToString(string viewPath, object model, ControllerContext controllerContext)
        {
            using (var writer = new StringWriter())
            {
                var view = new WebFormView(viewPath);
                var vdd = new ViewDataDictionary(model);
                var viewCxt = new ViewContext(controllerContext, view, vdd, new TempDataDictionary(), writer);
                viewCxt.ViewData = new ViewDataDictionary(model);
                viewCxt.View.Render(viewCxt, writer);
                return writer.ToString();
            }
        }
    }
}
